package com.audi.adapter;

import java.util.ArrayList;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.CheckBox;
import android.widget.TextView;

import com.audi.R;

//2-2-1 Already WiFi connected
public class HomeBoxTutorialAdapter extends BaseAdapter{
	private Activity mActivity;
	private ArrayList<Integer> listItem = new ArrayList<Integer>();

	public HomeBoxTutorialAdapter(Activity activity,
			ArrayList<Integer> mListContent) {
		mActivity = activity;
		listItem = mListContent;
	}

	public void removeItem(int pos) {
		listItem.remove(pos);
		notifyDataSetChanged();
	}

	@Override
	public int getCount() {
		return listItem.size();
	}

	@Override
	public Object getItem(int arg0) {
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		return 0;
	}

	@SuppressLint("InflateParams")
	@Override
	public View getView(int arg0, View convertView, ViewGroup arg2) {
		ViewHolder viewHolder = null;
		if (convertView == null) {
			viewHolder = new ViewHolder();
			convertView = LayoutInflater.from(mActivity).inflate(
					R.layout.row_homebox_tutorial, null);
			viewHolder.txtTile = (TextView) convertView
					.findViewById(R.id.txt_homebox_tutorial_title);
			viewHolder.txtContent = (TextView) convertView
					.findViewById(R.id.txt_homebox_tutorial_content);
			viewHolder.chxChecked = (CheckBox) convertView
					.findViewById(R.id.chx_homebox_tutorial_checked);
			convertView.setTag(viewHolder);
		} else {
			viewHolder = (ViewHolder) convertView.getTag();
		}
		if (listItem.get(arg0) == 1) {
			viewHolder.txtTile.setText(R.string.home_box_tutorial_b_title);
			viewHolder.txtContent.setText(R.string.home_box_tutorial_b_content);
		} else if (listItem.get(arg0) == 0) {
			viewHolder.txtTile.setText(R.string.row_homebox_tutorial_title);
			viewHolder.txtContent
					.setText(R.string.row_homebox_tutorial_content);
		}
		return convertView;
	}

	static class ViewHolder {
		public TextView txtTile;
		public TextView txtContent;
		public CheckBox chxChecked;

	}
}
